package com.example.demoserver.controller;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class test {
    public static void main(String[] args) {
        Connection conn = null;
        try {
            // db参数是你的数据库文件的路径，如果文件不存在，SQLite会创建一个新的数据库
            String url = "jdbc:sqlite:db.sqlite";
            // 创建一个数据库连接
            conn = DriverManager.getConnection(url);

            Statement stmt = conn.createStatement();
//            String sql = "CREATE TABLE IF NOT EXISTS house_partstore (\n"
//                    + "	id integer PRIMARY KEY AUTOINCREMENT,\n"
//                    + "	partName text NOT NULL,\n"
//                    + "	proCompany text NOT NULL,\n"
//                    + "	proTime text NOT NULL,\n"
//                    + "	comment text NOT NULL\n"
//                    + ");";
//            String sql1 = "CREATE TABLE IF NOT EXISTS house_part (\n"
//                    + "	id integer PRIMARY KEY AUTOINCREMENT,\n"
//                    + "	partBatch text NOT NULL,\n"
//                    + "	buyTime text NOT NULL,\n"
//                    + "	storeId text NOT NULL\n"
//                    + ");";
//            String sql2 = "CREATE TABLE IF NOT EXISTS house_product (\n"
//                    + "	id integer PRIMARY KEY AUTOINCREMENT,\n"
//                    + "	productId text,\n"
//                    + "	productName text NOT NULL,\n"
//                    + "	productType text NOT NULL,\n"
//                    + "	productBrand text NOT NULL,\n"
//                    + "	productTime text NOT NULL,\n"
//                    + "	partId text NOT NULL\n"
//                    + ");";
//            // 执行SQL语句，创建用户表
//            stmt.execute(sql);
//            stmt.execute(sql1);
//            stmt.execute(sql2);
//            String sql = "SELECT * from house_partstore where  proCompany like CONCAT('%','华北','%')";
//            stmt.execute(sql);
            LocalDateTime currentDateTime = LocalDateTime.now();
            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
            String formattedDateTime = currentDateTime.format(formatter);
            System.out.println(formattedDateTime);
        } catch (Exception e) {
            System.out.println(e.getMessage());
        } finally {
            try {
                if (conn != null) {
                    conn.close();
                }
            } catch (Exception ex) {
                System.out.println(ex.getMessage());
            }
        }

    }

}
